#ifndef TRANS_FUNC_GEN_H
#define TRANS_FUNC_GEN_H

#include "TFGenerator.h"
#include <map>

#define	DDDPair		pair<int,int>		//represents ball position
#define	DDDProb		pair< DDDPair, double> 
#define	DDDCount	std::map< DDDPair, int >	//distance -> counts
#define	DDDProbMap		std::map< DDDPair, double> //distance-> probability


#define	MAX_DIMENSION	5


class MREAgent;
class Lwpr; 
class LWPRLearner
	:public TFGenerator
{
private: 
	int action_number; 
	int obs_dim; 

	Lwpr** learners; 

	double avg_confidence; 

	bool priors [MAX_DIMENSION][MAX_DIMENSION] ;		//dim*dim matrix showing whether dim_i affects dim_j
	int priorCounts [MAX_DIMENSION];	//how many elements affect each dim_i

public:
	~LWPRLearner(); 
	LWPRLearner(MREAgent* p, int an, int od, taskspec_t& spec); 
	virtual void learn(const Transition* t); 
	virtual Observation predict(Observation st, Action a); 
	virtual double getConfidence(Observation st, Action a); 
	virtual void batchLearn(std::list<Transition>& history); 
	virtual void save(); 

	void learnBallMove(const Transition* t); 
	void predictBallMove(const Observation st, Observation end); 
	DDDCount ballMoveCnt; 
	DDDProbMap  ballMoveProb; 
	DDDProb* ballMoveProbHelper;	//this is an array that does the same thing as ballMoveProb but faster
	bool	dirty_flag;		//shows whether ballMoveProb is update or has to be recomputed

	double getAvgConfidence(){return stable_avg_confidence;}

	double min_confidence; 
	double max_confidence; 
	double count_confidence;	//used to compute avg
	bool   confidence_reset;	//should we reset confidence stat variables or not
	double stable_avg_confidence; 

	MREAgent* m_agent; 
};

#endif

